package com.hdd.art.biz.show.controller;

import com.hdd.art.biz.show.dto.*;
import com.hdd.art.biz.show.entity.OpenScreen;
import com.hdd.art.biz.show.entity.Showroom;
import com.hdd.art.biz.show.service.OpenScreenService;
import com.hdd.art.biz.show.service.ShowroomService;
import com.hdd.art.dto.AppResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/art-show/room")
@Api(value = "美术馆-展区",tags = {"美术馆-展区"})
public class ArtRoomController {

    @Autowired
    private ShowroomService showroomService;



    @PostMapping("/frontCover")
    @ApiOperation(value = "展区封面列表" ,notes = "")
    public AppResponse frontCover(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        List<FrontCoverVo> vos = new ArrayList<>();
        FrontCoverVo vo = new FrontCoverVo();
        vo.setId(100);
        vo.setUrl("https://img2.baidu.com/it/u=3617143252,3416123630&fm=26&fmt=auto&gp=0.jpg");
        vos.add(vo);

        FrontCoverVo vo1 = new FrontCoverVo();
        vo1.setId(102);
        vo1.setUrl("https://img2.baidu.com/it/u=3003152017,1280109034&fm=26&fmt=auto&gp=0.jpg");
        vos.add(vo1);

        FrontCoverVo vo2 = new FrontCoverVo();
        vo2.setId(102);
        vo2.setUrl(" https://img1.baidu.com/it/u=193271907,2092865989&fm=26&fmt=auto&gp=0.jpg");
        vos.add(vo2);

        response.setItems(vos);
        return response;
    }



    @PostMapping("/findArtRoomByArtId")
    @ApiOperation(value = "展区列表（根据美术馆取）" ,notes = "")
    public AppResponse findArtRoomById(@Valid @RequestBody ArtShowDo artShowDo ){
        AppResponse response = new AppResponse();
        List<Showroom> showrooms = showroomService.findShowroomByArtId(artShowDo.getArtId());
        showrooms.forEach(item -> item.setWorks(100));
        response.setItems(showrooms);
        return response;
    }

    @PostMapping("/addArtRoomById")
    @ApiOperation(value = "展区新增" ,notes = "")
    public AppResponse addArtRoomById(@Valid @RequestBody ShowRoomInfoDo showRoomInfoDo ){
        AppResponse response = new AppResponse();
        Showroom showroom = new Showroom();
        BeanUtils.copyProperties(showRoomInfoDo,showroom);
        showroom.setStatus("T");
        showroomService.addShowRoom(showroom);
        return response;
    }



    @PostMapping("/updateArtRoomById")
    @ApiOperation(value = "展区修改" ,notes = "")
    public AppResponse updateArtRoomById(@Valid @RequestBody ShowRoomInfoDo showRoomInfoDo ){
        AppResponse response = new AppResponse();
        Showroom showroom = new Showroom();
        BeanUtils.copyProperties(showRoomInfoDo,showroom);
        showroomService.updateShowRoom(showroom,showRoomInfoDo.getFontCoverId());
        return response;
    }


    @PostMapping("/delArtRoomById")
    @ApiOperation(value = "展区删除" ,notes = "")
    public AppResponse delArtRoomById(@Valid @RequestBody ShowRoomInfoDo showRoomInfoDo ){
        AppResponse response = new AppResponse();
        showroomService.delShowRoomById(showRoomInfoDo.getId());
        return response;
    }


}
